package xyz.chaobei.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

import java.util.UUID;

/**
 * Copyright (C), 2015-2020
 * FileName: ShiroUtil
 * Author:   MRC
 * Date:     2020/2/2 11:09
 * Description: 密码加密工具
 * History:
 */
public class PasswordUtil {


    /**
     * shiro 对应密码加密
     *
     * @return
     */
    public static String encryption(String pass, String salt, int hashNum) {
        SimpleHash simpleHash = new SimpleHash("md5", pass, ByteSource.Util.bytes(salt), hashNum);
        return simpleHash.toHex();
    }

    public static void main(String[] args) {
        String salt = UUID.randomUUID().toString();

        System.out.println(salt);

        String password = PasswordUtil.encryption("admin","admin"+salt,2);

        System.out.println(password);
    }

}